home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / OutOfContextMenus / Source / CNewCardBehavior.cp < prev    next >
Encoding:
Text File  |  1999-06-25  |  2.6 KB  |  112 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    CNewCardBehavior.cp                 ©1999 Eric Traut
  3. // ===========================================================================
  4.  
  5. #include "CNewCardBehavior.h"
  6. #include "CShadowWindow.h"
  7.  
  8.  
  9. // ---------------------------------------------------------------------------
  10. //        • CNewCardBehavior
  11. // ---------------------------------------------------------------------------
  12.  
  13. CNewCardBehavior::CNewCardBehavior(
  14.     CShadowWindow &        inShadowWindow)
  15.     :    COffscreenBehavior(inShadowWindow, true, true)
  16. {
  17.     mLastBlitTicks = ::TickCount();
  18.     mHOffset = 0;
  19.     mSlideDone = false;
  20. }
  21.  
  22.  
  23. // ---------------------------------------------------------------------------
  24. //        • SyncWithShadowWindow
  25. // ---------------------------------------------------------------------------
  26.  
  27. Boolean
  28. CNewCardBehavior::SyncWithShadowWindow(void)
  29. {
  30.     Boolean            didSync;
  31.     
  32.     didSync = COffscreenBehavior::SyncWithShadowWindow();
  33.     
  34.     if (didSync)
  35.     {
  36.         // Recalculate our blur rect
  37.         CWindowRecord *        macWindow = mShadowWindow.GetMacWindow();
  38.         mInvertRect = macWindow->port.portRect;
  39.         
  40.         mInvertRect.right -= 15;
  41.         mInvertRect.bottom -= 15;
  42.         mInvertRect.top += 21;
  43.     }
  44.     
  45.     return didSync;
  46. }
  47.  
  48.         
  49. // ---------------------------------------------------------------------------
  50. //        • RenderToGWorld
  51. // ---------------------------------------------------------------------------
  52.  
  53. Boolean
  54. CNewCardBehavior::RenderToGWorld(
  55.     StGWorldLocker &        inBackingLocker,
  56.     StGWorldLocker &        inRenderingLocker)
  57. {
  58.     if (!mSlideDone)
  59.     {
  60.         // Split the blit into two halves.
  61.         Rect        destRect;
  62.         UInt32        gworldWidth = mGWorldRect.right - mGWorldRect.left;
  63.  
  64.         destRect = mGWorldRect;
  65.         ::OffsetRect(&destRect, -mHOffset, 0);
  66.         ::CopyBits(    reinterpret_cast<BitMap *>(*inBackingLocker.GetPixMap()),
  67.                     reinterpret_cast<BitMap *>(*inRenderingLocker.GetPixMap()),
  68.                     &mGWorldRect,
  69.                     &destRect,
  70.                     srcCopy,
  71.                     NULL);
  72.  
  73.         destRect = mGWorldRect;
  74.         ::OffsetRect(&destRect, gworldWidth - mHOffset, 0);
  75.         ::CopyBits(    reinterpret_cast<BitMap *>(*inBackingLocker.GetPixMap()),
  76.                     reinterpret_cast<BitMap *>(*inRenderingLocker.GetPixMap()),
  77.                     &mGWorldRect,
  78.                     &destRect,
  79.                     srcCopy,
  80.                     NULL);
  81.  
  82.         mHOffset += 10;
  83.  
  84.         if (mHOffset >= gworldWidth)
  85.             mSlideDone = true;
  86.     }
  87.     
  88.     return true;
  89. }
  90.  
  91.  
  92. // ---------------------------------------------------------------------------
  93. //        • DoIdleTask
  94. // ---------------------------------------------------------------------------
  95.  
  96. void
  97. CNewCardBehavior::DoIdleTask(
  98.     Boolean     inGNETime)
  99. {
  100.     if (inGNETime && mSlideDone)
  101.     {
  102.         // Detach ourselves
  103.         mShadowWindow.DetachBehavior();
  104.     }
  105.     else
  106.     {
  107.         COffscreenBehavior::DoIdleTask(inGNETime);
  108.     }
  109. }
  110.  
  111.  
  112.